import React, { Component } from 'react'
import {
  Image,
  ScrollView,
  StyleSheet,
  WebView,
  Platform,
  TouchableOpacity,
  Text,
  View,
  Dimensions,
} from 'react-native'
import ViewUtils from '../util/ViewUtils'

const TRENDING_URL = 'https://github.com/'
export default class RepositoryDetail extends Component {
  static navigationOptions = ({ navigation }) => ({
    headerTitle: navigation.state.params.title,
    headerStyle: { backgroundColor: '#2196F3' },
    headerTitleStyle: { alignSelf: 'center', color: 'white' },
    headerRight: ViewUtils.rightFavoriteButton(),
    gesturesEnabled: true,
  })

  constructor(props) {
    super(props);
    this.url = this.props.navigation.state.params.url ? this.props.navigation.state.params.url
      : TRENDING_URL + this.props.navigation.state.params.title;
  }

  render() {
    return (
      <View style={styles.container}>
        <WebView
          source={{ uri: this.url }}
          startInLoadingState={true}
          userAgent="Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Mobile Safari/537.36"
        />
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#ffffff',
  },
})


